package com.ctl.model.listener;

import lombok.extern.slf4j.Slf4j;
import org.springframework.context.ApplicationEvent;
import org.springframework.context.ApplicationListener;
import org.springframework.context.event.ContextRefreshedEvent;
import org.springframework.stereotype.Component;
import org.springframework.stereotype.Service;

@Slf4j
@Component
public class ModelApplicationListener implements ApplicationListener<ContextRefreshedEvent> {
    @Override
    public void onApplicationEvent(ContextRefreshedEvent evt) {
        log.info("通过实现ModelApplicationListener接口，在spring boot项目启动后执行一些操作");
        if (evt.getApplicationContext().getParent() == null) {
            log.info("启动完毕开始初始化,可以开始做些初始化操作");
        }
    }
}